package com.bby.user.controller;

import cn.hutool.core.util.ObjectUtil;
import com.bby.common.exception.BBYException;
import com.bby.common.model.UserPublicInfo;
import com.bby.common.utils.R;
import com.bby.user.manager.TokenManager;
import com.bby.user.service.UserService;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户-微服务接口
 */
@RestController
@RequestMapping("admin")
public class UserEurekaApi {
    TokenManager tokenManager;
    UserService userService;

    public UserEurekaApi(TokenManager tokenManager, UserService userService) {
        this.tokenManager = tokenManager;
        this.userService = userService;
    }

    /**
     * 批量获取用户公共信息
     * @return json数据
     */
    @ResponseBody
    @PostMapping("getPubInfos")
    public List<UserPublicInfo> getUserPubInfos(@RequestBody List<String> ids) throws BBYException {
        if (ids==null) {
            return new ArrayList<>();
        }
        return userService.getUserPublicInfoByIds(ids);
    }
//    /**
//     * 获取用户信息
//     * @param token
//     */
//    @GetMapping ("userInfo")
//    public String getUserInfo(String token){
//        return userInfoDao.findUserInfoById(tokenManager.readUserId(token)).toString();
//    }
}
